package com.yuantong.xyerp.core.provider.dao;

import com.yuantong.xyerp.core.api.model.Area;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AreaMapper {

    @Results(id = "Area",value = {
            @Result(property = "id",column = "id"),
            @Result(property = "code",column = "code"),
            @Result(property = "name",column = "name")
    })
    @Select("SELECT id,code,name FROM t_area")
    List<Area> findAll();

    @Select({"<script> " +
            "SELECT name FROM t_area a " +
            "WHERE 1=1 " +
            "<if test=\"codes != null and codes.size() > 0\"> " +
            "AND a.code IN " +
            "<foreach collection=\"codes\" item=\"code\" open=\"(\" close=\")\" separator=\",\"> " +
            "#{code} " +
            "</foreach> " +
            "</if> " +
            "</script>"})
    List<String> findAreaNameByCodes(@Param("codes") List<String> codes);
}
